<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>查看用户</title>
    <!-- 引入jQuery库 -->
    <script src="/secondhand/js/jquery-3.2.1.js"></script>
</head>
<body>
<h2>用户信息</h2>

<!-- 显示用户信息 -->
<p>用户ID: <span id="userid">-</span></p>
<p>用户名: <span id="username">-</span></p>
<p>姓名: <span id="userfullname">-</span></p>
<p>电话: <span id="phone">-</span></p>

<br>
<!-- 操作按钮 -->
<input type="button" value="删除" onclick="deleteUser()">
<a href="/secondhand/toList.goods?pageNo=1&likeValue=">
    <input type="button" value="返回" >
</a>


<script>
    // 页面加载完成时执行
    $(document).ready(function() {
        loadUserInfo();  // 加载用户信息
    });

    // 加载并显示用户信息
    function loadUserInfo() {
        $.post("/secondhand/viewUser.User",
            function(data) {
                // 显示用户信息
                $("#userid").text(data.user.userid);
                $("#username").text(data.user.username);
                $("#userfullname").text(data.user.userfullname);
                $("#phone").text(data.user.phone);
            }
        );
    }

    // 删除用户
    function deleteUser() {
        // 确认是否删除
        if (confirm("确定要注销该用户吗？")) {
            $.post("/secondhand/deleteUser.User",
                function(data) {
                    // 提示删除成功并跳转
                    alert("删除成功");
                    window.top.location.href = "/secondhand/login.html";
                }
            );
        }
    }

</script>
</body>
</html>
